var menuId = 0;
// Called when a message is passed.  We assume that the content script
// wants to show the page action.
function onRequest(request, sender, sendResponse) {
  // Show the page action for the tab that the sender (content script)
  // was on.
  if(request.show) {
    chrome.pageAction.show(sender.tab.id);
    chrome.pageAction.setPopup({tabId: sender.tab.id, popup: "popup.html?" + JSON.stringify(request)});
  } else {
    chrome.pageAction.hide(sender.tab.id);
  }

  // Return nothing to let the connection be cleaned up.
  sendResponse({});
};

// Listen for the content script to send a message to the background page.
chrome.extension.onRequest.addListener(onRequest);